﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="TitleDetailsPage.xaml.cs" company="saramgsilva">
//   Copyright (c) 2012 saramgsilva. All rights reserved.
// </copyright>
// <summary>
//   The title details page.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace Netflix.ClientApp.View
{
    using System.Windows.Navigation;

    using Netflix.PortableClassLibrary.Model;
    using Netflix.PortableClassLibrary.ViewModel;

    /// <summary>
    /// The title details page.
    /// </summary>
    public partial class TitleDetailsPage
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="TitleDetailsPage"/> class.
        /// </summary>
        public TitleDetailsPage()
        {
            InitializeComponent();
        }

        /// <summary>
        /// Called when a page becomes the active page in a frame.
        /// </summary>
        /// <param name="e">An object that contains the event data.</param>
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            if (e.NavigationMode == NavigationMode.New || e.NavigationMode == NavigationMode.Refresh)
            {
                var titleDetailsViewModel = DataContext as TitleDetailsViewModel;
                if (titleDetailsViewModel != null)
                {
                    titleDetailsViewModel.LoadData(Services.NavigationService.DecodeNavigationParameter<MyTitle>(NavigationContext));
                }
            }
        }
    }
}